package com.zl.quickdoc;

import com.zl.quickdoc.format.impl.ApiFormatExcel;
import com.zl.quickdoc.format.impl.ApiFormatHtml;
import com.zl.quickdoc.format.impl.ApiFormatJavaclass;
import com.zl.quickdoc.format.impl.ApiFormatMarkdown;
import com.zl.quickdoc.format.impl.ApiFormatWord;
import com.zl.quickdoc.framework.impl.SpringWebHttpFramework;
import com.zl.quickdoc.model.DocCfgParam;

/**
 * 生成文档主类
 * @author zhouliang
 *
 */
public class SpringApiHelper {
    
    static SpringApiFactory springDoc = null;
    
    static SpringApiFactory init(DocCfgParam p){
        if(springDoc == null) {
             springDoc = new SpringApiFactory(new SpringWebHttpFramework(p),p);
        }
        return springDoc;
    }
    
    /**
     * 生成html文档
     */
    public static void htmlDoc(DocCfgParam p) throws Exception{
        init(p).build(new ApiFormatHtml());
    }
    /**
     * 生成java测试类文档
     */
    public static void javaTestDoc(DocCfgParam p) throws Exception{
        init(p).build(new ApiFormatJavaclass());
    }
    
    /**
     * 生成word文档
     */
    public static void wordDoc(DocCfgParam p) throws Exception{
        init(p).build(new ApiFormatWord());
    }
    
    /**
     * 生成markdown文档
     */
    public static void markdownDoc(DocCfgParam p) throws Exception{
        init(p).build(new ApiFormatMarkdown());
    }
    
    /**
     * 生成excel文档
     */
    public static void excelDoc(DocCfgParam p) throws Exception{
        init(p).build(new ApiFormatExcel());
    }
}
